using Microsoft.Phone.Tasks;
using System.Windows.Input;
using System;
using TaxiPlease.PhoneHelpers;

namespace TaxiPlease
{
	public class CallCommand : ICommand
	{
		private readonly OptionsViewModel options;

		public CallCommand(OptionsViewModel options)
		{
			this.options = options;
		}

		public bool CanExecute(object parameter)
		{
			return this.options != null && !string.IsNullOrEmpty(this.options.TaxiPhoneNumber);
		}

		public event EventHandler CanExecuteChanged;

		public void Execute(object parameter)
		{
			//LocationHelper location = new LocationHelper();
			//location.GetAddress(Call);
			//
			Call();
		}

		public void Call()
		{
			PhoneCallTask phoneCall = new PhoneCallTask
			{
				PhoneNumber = options.TaxiPhoneNumber,
				DisplayName = "Taxi"
			};

			phoneCall.Show();
		}
	}
}